"use strict"

const moment = require('moment')
module.exports = app => {
    const { STRING, DATE, INTEGER } = app.Sequelize
    const Imgs = app.model.define('imgs', {
        id: {
            type: INTEGER,
            autoIncrement: true,
            primaryKey: true,
        },
        admin_id: {
            type: INTEGER,
            allowNull: false
        },
        path: {
            type: STRING,
            allowNull: false
        },
        mkdir: {
            type: STRING,
            allowNull: false
        },
        filename: {
            type: STRING,
            allowNull: false
        },            
        create_time: {
            type: DATE,
            allowNull: false,
            get() {
                return moment(this.getDataValue('create_time')).format('YYYY-MM-DD h:i:s')
            }
        },
    }) 

    return Imgs
}